import Mock from "mockjs";

const { data } = Mock.mock({
  // 20条数据
  "data|66": [
    {
      // 商品种类
      goodsClass: "女装",
      // 商品Id
      "goodsId|+1": 1,
      //商品名称
      goodsName: "@ctitle(3)",
      name: "@cname",
      //商品地址
      goodsAddress: "@county(true)",
      //商品等级评价★
      "goodsStar|1-5": "★",
      //商品图片
      goodsImg: "@Image('100x100','@color','小甜甜')",
      //商品售价
      "goodsSale|30-500": 30,
    },
  ],
});

class NewsServer {
  getData(params) {
    const { pageSize = 10, currentPage = 1 } = params;
    const result = data.slice(
      (currentPage - 1) * pageSize,
      currentPage * pageSize
    );
    return new Promise((resolve) => {
      resolve({
        status: 0,
        list: result,
        count: data.length,
      });
    });
  }
  addData(params) {
    data.unshift(params);
    return new Promise((resolve) => {
      resolve({
        status: 0,
        msg: "添加成功",
      });
    });
  }
  delData() {}
  delDatas(params) {
    console.log(params.ids);
  }
}

const news = new NewsServer();
export default news;
